<!-- 发布文章 -->
<template>
  <div>
      <Form ref="formInline" :model="formInline">
        <FormItem prop="user">
            <Input type="text" v-model="title" placeholder="文章标题">
            </Input>
        </FormItem>
        <FormItem prop="password">
            <Input type="textarea" v-model="content" placeholder="文章内容">
            </Input>
        </FormItem>
        <FormItem>
            <Button type="primary" @click="handleSubmit">发布</Button>
        </FormItem>
    </Form>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  data () {
    return {
        title: '',
        content: ''
    }
  },

  components: {},

  computed: {},

  methods: {
      handleSubmit() {
          const self = this
          if (self.title === '' || self.content === ''){
              this.$Message.error('文章或者标题是空')
              return
          }
          axios('/newArticle', {
            method: 'POST',
            params:{
              title: self.title,
              content: self.content,
              autor: "Auto"
            }
          }).then(res => {
            this.$Message.success('发布成功')
            self.title = ''
            self.content =''
          }).catch(err => {
              this.$Message.error('发布失败')
          })
      }
  }
}

</script>
<style scoped>
</style>